package jznet 
import (
        "net"
    )
    
const (
        T_MSEC = 2000,
    )
    
type jzTCPService struct {
    port string
    name string
    listener *net.TCPListener
}

func NewTCPService(name string) *jzTCPService {
    tcp = &jzTCPService {
            name:name,
    }
}

func (jzTcpService* jzTCPService) Bind(port string) bool {
    addr,_ :=  net.ResolveTCPAddr("tcp",port)
    listener,err := net.ListenTCP("tcp",addr)
    if err != nil {
        return false
    }
    jzTcpService.listener = listener
    return true
}

func (jzTcpService* jzTCPService) Accept() (net.Conn,error) {
    return jzTcpService.listener.Accept()
}

func (jzTcpService *jzTCPService) Final() {
    jzTcpService.listener.Close()
}